package org.testis.gui.mvc.controller.testdesign;

import org.testis.gui.mvc.controller.*;
import org.testis.gui.mvc.model.testdesign.TestStepModel;
import org.testis.gui.mvc.view.testdesign.TestStepView;
import org.testis.orm.testbed.refined.DutRefined;
import org.testis.orm.testbed.refined.NetworkAdapterRefined;
import org.testis.orm.testbed.refined.TestPcFactory;
import org.testis.orm.testbed.refined.TestPcRefined;
import org.testis.testdriver.AtofEnumaration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.orm.PersistentException;
import org.testis.orm.refinedclasses.DataObjectRefined;
import org.testis.orm.refinedclasses.TestCaseRefined;
import org.testis.orm.refinedclasses.TestDesignTreeNode;
import org.testis.orm.refinedclasses.TestStepGroupRefined;
import org.testis.orm.refinedclasses.TestStepRefined;
import org.testis.orm.refinedclasses.TestDesignTreeRefined.TestDesignTreeParameters;
import org.testis.orm.testdesign.TestPartSaver;
import org.testis.utils.middleware.TestDesign;
import org.testis.utils.tree.TreeNode;

/**
 *
 * @author Cahit Emir Erel
 */
public class TestStepController extends AbstractController implements SaveAble, Addable {

    public static final String CHANGE_NAME = "Name";
    public static final String CHANGE_DESCRIPTION = "Description";
    public static final String CHANGE_SUPPORTED_DEVICE_GROUP = "SupportedDeviceGroup";
    public static final String CHANGE_ACTION = "Action";
    public static final String CHANGE_DATA_ARRAY_APPLIES_TO_CASE = "DataArrayAppliesToCase";
    public static final String CHANGE_DELAY_TIME = "DelayTime";
    public static final String CHANGE_AFTER_DELAY_TIME = "AfterDelayTime";
    public static final String CHANGE_STORE_RESULT_POSTFIX = "StoreResultPostfix";
    public static final String CHANGE_ASYNCH_CALL = "ASynchCall";
    public static final String CHANGE_NUMBER_OF_RETRY_ON_FAIL = "NumberOfRetryOnFail";
    public static final String CHANGE_CRITICAL = "Critical";
    public static final String CHANGE_SUCCESS_PERCENTAGE = "SuccessPercentage";
    public static final String CHANGE_TIMEOUT = "Timeout";
    public static final String CHANGE_MODULE_TYPE = "ModuleType";
    public static final String CHANGE_PC = "Pc";
    public static final String CHANGE_BROWSER_SPEED = "BrowserSpeed";
    public static final String CHANGE_BROWSER_TYPE = "BrowserType";
    public static final String CHANGE_DEVICE = "Device";
    public static final String CHANGE_DUT_IP = "DutIp";
    public static final String SHOW_ADD_TEST_STEP = "TestStepVisibility";
    public static final String CHANGE_LAST_WARNING = "LastWarning";
    private TestDesignTreeNode m_selectedNode = null;

    public TestStepController() {
        super();
        TestDesignControllerList.newInstance().setTestStepController(this);
    }

    public void operationCloseWindow() {
        this.cleanAll();
    }

    public String[] operationGetModulTypeList() {
        return TestDesign.newInstance().getModuleTypeListNames();
    }

    public String[] operationGetActionList(String modulTypeName) {
        return TestDesign.newInstance().getActionNamesByModulType(modulTypeName);
    }

    public List<DutRefined> operationGetDutList() {
        Integer pcId = (Integer) getModelProperty(CHANGE_PC);
        TestPcRefined ref = TestPcFactory.newInstance().getTestPc(pcId);
        if (ref == null) {
            return null;
        }
        return ref.getDutList();
    }

    public List<TestPcRefined> operationGetPcList() {
        return TestPcFactory.newInstance().getTestPcList();
    }

    public String[] operationGetBrowserTypes() {
        String[] result = {"chrome", "iehta", "firefox", "iexplore"};
        return result;
    }

    public List<NetworkAdapterRefined> operationGetNetworkCardList() {
        Integer pcId = (Integer) getModelProperty(CHANGE_PC);
        TestPcRefined ref = TestPcFactory.newInstance().getTestPc(pcId);
        if (ref == null) {
            return null;
        }
        return ref.getNetworkAdapterList();
    }

    public void operationAddTestStep(HashMap<String, Object> params) throws PersistentException {
        TestDesignTreeNode node = TestDesignControllerList.newInstance().
                getTreeController().getSelectedTreeNode();
        TestDesignControllerList.newInstance().getTreeController().operationHandleAdd(
                this, node, params);
    }

    public void operationSaveTestStep(HashMap<String, Object> params) {
        TestDesignControllerList.newInstance().getTreeController().
                operationHandleSaveClones(this,
                m_selectedNode,
                params);
    }

    @Override
    public boolean operationSave(HashMap<String, Object> params,
            TreeNode node,
            boolean dynamicSaveOnly) {

        if (dynamicSaveOnly) {
            params.put("dynamicSaveOnly", "true");
        }
        return TestPartSaver.operationSave(params,
                (TestDesignTreeNode) node);
    }

    public String[] operationGetSupportedDeviceList() {
        return TestDesign.newInstance().getSupportedDeviceNames();
    }

    public void operationNewTestStep() {
        initialize(false);
        m_selectedNode = TestDesignControllerList.newInstance().getTreeController().getSelectedTreeNode();
        TestDesignControllerList.newInstance().getLabelPairSettingsController().operationNewSettings();
        setModelProperty(SHOW_ADD_TEST_STEP,
                true);
    }

    public void initialize(boolean editMode) {
        TestStepModel testStepModel = new TestStepModel();
        java.awt.Frame frame = TestDesignControllerList.newInstance().getParentFrame();
        TestStepView testStepView = new TestStepView(frame, true, editMode);
        super.addModel(testStepModel);
        super.addView(testStepView);
        testStepView.pack();
    }

    public void operationEditTestStep(TestDesignTreeNode node) {
        if (node.getReference().getType() == null) {
            System.out.println("Not found reference type for test step");
            return;
        } else if (node.getReference().getType().getName() == null) {
            System.out.println("Not found reference type name for test step");
            return;
        }
        if (node.getReference().getType().getName().equals("TestStep")) {
            initialize(true);
            TestStepRefined designpart = null;
            try {
                designpart = (TestStepRefined) node.getObject();
            } catch (Exception ex) {
                System.out.println(ex.toString());
            }
            if (designpart == null) {
                System.out.println("Not found design part for test step");
                return;
            }

            setModelProperty(CHANGE_NAME, designpart.getName());

            setModelProperty(CHANGE_DESCRIPTION,
                    designpart.getReference().getDescription());
            String moduleType = TestDesign.getModuleTypeName(
                    designpart.getReference().getModulTypeId());
            String actionType = TestDesign.getActionTypeName(
                    designpart.getReference().getActionId());
            String supportedDeviceGroup = TestDesign.getSupportedDeviceGroupName(
                    designpart.getReference().getSupportedDeviceGroupId());

            if (isValid(moduleType,
                    "module type")) {
                setModelProperty(
                        CHANGE_MODULE_TYPE,
                        moduleType);
            }

            if (isValid(actionType,
                    "action")) {
                setModelProperty(CHANGE_ACTION,
                        actionType);
            }

            if (isValid(supportedDeviceGroup,
                    "supported device group")) {
                setModelProperty(CHANGE_SUPPORTED_DEVICE_GROUP,
                        supportedDeviceGroup);
            }
            String browserType = node.getReference().getParameterStringValue(
                    TestDesignTreeParameters.BrowserType.name());
            Integer browserSpeed = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.BrowserSpeed.name());
            if (browserSpeed != null) {
                setModelProperty(CHANGE_BROWSER_SPEED,
                        browserSpeed);
            }
            if (browserType != null) {
                setModelProperty(CHANGE_BROWSER_TYPE,
                        browserType);
            }

            String deviceIp = node.getReference().getParameterStringValue(
                    TestDesignTreeParameters.DeviceIp.name());

            if (deviceIp != null) {
                setModelProperty(
                        CHANGE_DUT_IP, deviceIp);
            }
            Boolean dataApplies = node.getReference().getParameterBooleanValue(
                    TestDesignTreeParameters.DataArrayAppliestoCase.name());
            if (dataApplies != null) {
                setModelProperty(CHANGE_DATA_ARRAY_APPLIES_TO_CASE,
                        dataApplies);
            }
            Byte successPercent = node.getReference().getParameterByteValue(
                    TestDesignTreeParameters.SuccessPercentage.name());
            if (successPercent != null) {
                setModelProperty(CHANGE_SUCCESS_PERCENTAGE,
                        successPercent);
            }


            Integer deviceId = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.DeviceId.name());
            Integer nicId = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.NicId.name());
            Integer pcId = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.PcId.name());
            if (pcId != null) {
                setModelProperty(CHANGE_PC, pcId);
            }
            if (deviceId != null) {
                setModelProperty(CHANGE_DEVICE,
                        deviceId);
            } else if (nicId != null) {
                setModelProperty(CHANGE_DEVICE,
                        nicId);
            } else {
                System.out.println("Not found dut device for test plan");
            }
            Boolean asycn = node.getReference().getParameterBooleanValue(
                    TestDesignTreeParameters.AsynchCall.name());
            if (asycn != null) {
                setModelProperty(CHANGE_ASYNCH_CALL,
                        asycn);
            }
            Boolean critical = node.getReference().getParameterBooleanValue(
                    TestDesignTreeParameters.Critical.name());
            if (critical != null) {
                setModelProperty(CHANGE_CRITICAL,
                        critical);
            }
            Integer delayTime = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.DelayTime.name());
            if (delayTime != null) {
                setModelProperty(CHANGE_DELAY_TIME,
                        delayTime);
            }
            Integer afterdelayTime = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.AfterDelayTime.name());
            if (afterdelayTime != null) {
                setModelProperty(CHANGE_AFTER_DELAY_TIME,
                        afterdelayTime);
            }
            String storeResultPostfix = node.getReference().getParameterStringValue(
                    TestDesignTreeParameters.StoreResultPostfix.name());
            if (storeResultPostfix != null) {
                setModelProperty(CHANGE_STORE_RESULT_POSTFIX,
                        storeResultPostfix);
            }
            Integer noOfRetry = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.NoOfRetryOnFail.name());
            if (noOfRetry != null) {
                setModelProperty(CHANGE_NUMBER_OF_RETRY_ON_FAIL,
                        noOfRetry);
            }
            Integer timeout = node.getReference().getParameterIntValue(
                    TestDesignTreeParameters.Timeout.name());
            if (timeout != null) {
                setModelProperty(CHANGE_TIMEOUT,
                        timeout);
            }

            TestDesignControllerList.newInstance().getLabelPairSettingsController().operationEditSettings(
                    node);

            m_selectedNode = node;
            setModelProperty(SHOW_ADD_TEST_STEP, true);
        }
    }

    public boolean isValid(Object obj,
            String errMsg) {
        if (obj != null) {
            return true;
        } else {
            System.out.println("Not found " + errMsg + " for test step");
        }
        return false;
    }

    public void operationChangeName(String name) {
        setModelProperty(CHANGE_NAME,
                name);
    }

    public void operationChangeDescription(String description) {
        setModelProperty(CHANGE_DESCRIPTION,
                description);
    }

    public void operationChangeTimeout(String timeout) {
        setModelProperty(CHANGE_TIMEOUT,
                Integer.parseInt(timeout));
    }

    public void operationChangeSupportedDeviceGroup(String SupportedDeviceGroup) {
        setModelProperty(CHANGE_SUPPORTED_DEVICE_GROUP,
                SupportedDeviceGroup);
    }

    public void operationChangeAction(String action) {
        setModelProperty(CHANGE_ACTION,
                action);
    }

    public void operationChangeDataArrayAppliesToCase(
            String DataArrayAppliesToCase) {
        setModelProperty(CHANGE_DATA_ARRAY_APPLIES_TO_CASE,
                Boolean.parseBoolean(DataArrayAppliesToCase));
    }

    public void operationChangeAfterDelayTime(String afterDelayTime) {
        setModelProperty(CHANGE_AFTER_DELAY_TIME,
                Integer.parseInt(afterDelayTime));
    }

    public void operationChangeDelayTime(String DelayTime) {
        setModelProperty(CHANGE_DELAY_TIME,
                Integer.parseInt(DelayTime));
    }

    public void operationChangeASynchCall(String ASynchCall) {
        setModelProperty(CHANGE_ASYNCH_CALL,
                Boolean.parseBoolean(ASynchCall));
    }

    public void operationChangeNumberOfRetryOnFail(
            String noOfRetryOnFail) {
        setModelProperty(CHANGE_NUMBER_OF_RETRY_ON_FAIL,
                Integer.parseInt(noOfRetryOnFail));
    }

    public void operationChangeCritical(String critical) {
        setModelProperty(CHANGE_CRITICAL,
                Boolean.parseBoolean(critical));
    }

    public void operationChangeSuccessPercentage(String SuccessPercentage) {
        setModelProperty(CHANGE_SUCCESS_PERCENTAGE,
                Byte.parseByte(SuccessPercentage));
    }

    public void operationChangeModulType(String ModuleType) {
        setModelProperty(CHANGE_MODULE_TYPE,
                ModuleType);
    }

    public void operationChangePc(Integer pc) {
        setModelProperty(CHANGE_PC,
                pc);
    }

    public void operationChangeBrowserSpeed(String browserSpeed) {
        setModelProperty(CHANGE_BROWSER_SPEED,
                Integer.parseInt(browserSpeed));
    }

    public void operationChangeBrowserType(String browserType) {
        setModelProperty(CHANGE_BROWSER_TYPE,
                browserType);
    }

    public void operationChangeDevice(Integer device) {
        setModelProperty(CHANGE_DEVICE,
                device);
    }

    public void operationChangeDutIp(String dutIp) {
        setModelProperty(CHANGE_DUT_IP,
                dutIp);
    }

    private boolean checkIfAsyncAndDataAppliesToCaseForUniqueDut() {
        String modulType = (String) getModelProperty(CHANGE_MODULE_TYPE);
        Boolean aSynchCallChoice =
                (Boolean) getModelProperty(CHANGE_ASYNCH_CALL);
        Boolean dataArrayAppliesToCaseChoice = (Boolean) getModelProperty(
                CHANGE_DATA_ARRAY_APPLIES_TO_CASE);
        boolean result = true;
        int currentStepId = 0;
        if (!modulType.equals(
                AtofEnumaration.AtofModule.WebAutomationModule.name())) {
            return true;
        }
        if (!aSynchCallChoice) {
            return true;
        }
        if (!dataArrayAppliesToCaseChoice) {
            return true;
        }
        TestDesignTreeNode selectedNode = TestDesignControllerList.newInstance().
                getTreeController().getSelectedTreeNode();
        TestDesignTreeNode currentTestCase = null;
        if (selectedNode.getObject() instanceof TestStepRefined) {
            //editing a test step
            currentTestCase = selectedNode.getParent();
            currentStepId = ((TestStepRefined) selectedNode.getObject()).getReference().getId();

        } else if (selectedNode.getObject() instanceof TestCaseRefined) {
            //adding new test step
            currentTestCase = selectedNode;
        } else if (selectedNode.getObject() instanceof TestStepGroupRefined) {
            //adding new test step
            currentTestCase = selectedNode;
        }
        List<TestDesignTreeNode> currentTestStepList = new ArrayList();
        TestDesignTreeNode[] currentList =
                currentTestCase.getChildren();
        for (int i = 0; i < currentList.length; i++) {
            TestDesignTreeNode testDesignTreeNode = currentList[i];
            if (testDesignTreeNode.getObject() instanceof TestStepRefined) {
                currentTestStepList.add(testDesignTreeNode);
            }
        }
        TestDesignTreeNode[] currentTestSteps =
                new TestDesignTreeNode[currentTestStepList.size()];
        for (int i = 0; i < currentTestSteps.length; i++) {
            currentTestSteps[i] = currentTestStepList.get(i);
        }

        Integer selectedDevice = (Integer) getModelProperty(CHANGE_DEVICE);
        Integer selectedPc = (Integer) getModelProperty(CHANGE_PC);
        if (selectedPc == null) {
            selectedPc = 0;
        }
        if (selectedDevice == null) {
            selectedDevice = 0;
        }
        Integer tmpPc = 0;
        Integer tmpDevice = 0;

        for (int i = 0; i < currentTestSteps.length; i++) {
            TestStepRefined testStepRefined =
                    (TestStepRefined) currentTestSteps[i].getObject();
            String moduleType = TestDesign.getModuleTypeName(
                    testStepRefined.getReference().getModulTypeId());

            int id = testStepRefined.getReference().getId();
            if (moduleType.equals(
                    AtofEnumaration.AtofModule.WebAutomationModule.name()) && id != currentStepId) {
                Integer pcId = currentTestSteps[i].getReference().getParameterIntValue(
                        TestDesignTreeParameters.PcId.name());
                Integer deviceId = currentTestSteps[i].getReference().getParameterIntValue(
                        TestDesignTreeParameters.DeviceId.name());
                tmpDevice = 0;
                tmpPc = 0;
                TestPcRefined pcData = null;
                if (pcId != null) {
                    pcData = TestPcFactory.newInstance().getTestPc(pcId);
                    if (pcData != null) {
                        tmpPc = pcData.getId();
                    }

                }
                if (pcData != null) {
                    if (deviceId != null) {
                        DutRefined refDut = pcData.getDut(deviceId);
                        if (refDut != null) {
                            tmpDevice = refDut.getId();
                        }
                    }
                }
                if (tmpDevice.intValue() == selectedDevice.intValue() && tmpPc.intValue() == selectedPc.intValue()) {
                    result = false;
                    break;
                }
            }
        }
        if (!result) {
            setModelProperty(CHANGE_LAST_WARNING,
                    "You have to select another dut device for this async. test step..."
                    + "Because test step is async and data array applies to case.");

        }
        return result;
    }

    private boolean checkIfDataAppliesToCaseDataCountsCorrect() {
        Boolean dataArrayAppliesToCaseChoice = (Boolean) getModelProperty(
                CHANGE_DATA_ARRAY_APPLIES_TO_CASE);
        if (!dataArrayAppliesToCaseChoice) {
            return true;
        }
        TestDesignTreeNode selectedNode = TestDesignControllerList.newInstance().
                getTreeController().getSelectedTreeNode();
        TestDesignTreeNode currentTestCase = null;
        boolean isEditing = false;
        int currentTestStepId = 0;
        if (selectedNode.getObject() instanceof TestStepRefined) {
            //editing a test step
            currentTestCase = selectedNode.getParent();
            currentTestStepId = selectedNode.getReference().getId();
        } else if (selectedNode.getObject() instanceof TestCaseRefined) {
            //adding new test step
            currentTestCase = selectedNode;
            isEditing = true;
        } else if (selectedNode.getObject() instanceof TestStepGroupRefined) {
            //adding new test step
            currentTestCase = selectedNode;
            isEditing = true;
        }
        List<TestDesignTreeNode> currentTestStepList = new ArrayList();
        TestDesignTreeNode[] currentList =
                currentTestCase.getChildren();
        for (int i = 0; i < currentList.length; i++) {
            TestDesignTreeNode testDesignTreeNode = currentList[i];
            if (testDesignTreeNode.getObject() instanceof TestStepRefined) {
                currentTestStepList.add(testDesignTreeNode);
            }
        }
        TestDesignTreeNode[] currentTestSteps =
                new TestDesignTreeNode[currentTestStepList.size()];
        for (int i = 0; i < currentTestSteps.length; i++) {
            currentTestSteps[i] = currentTestStepList.get(i);
        }
        StringBuffer statusOfAllNodes = new StringBuffer();
        int maxCount = 0;
        for (int i = 0; i < currentTestSteps.length; i++) {
            TestDesignTreeNode testDesignTreeNode = currentTestSteps[i];
            Boolean curDataArray = testDesignTreeNode.getReference().getParameterBooleanValue(
                    TestDesignTreeParameters.DataArrayAppliestoCase.name());
            if (curDataArray == null) {
                curDataArray = false;
            }
            if (curDataArray && testDesignTreeNode.getReference().
                    getId() != currentTestStepId) {
                if (testDesignTreeNode.getChildren().length > maxCount) {
                    maxCount =
                            testDesignTreeNode.getChildren().length;
                }
                statusOfAllNodes.append(" Step Name:" + testDesignTreeNode.getName() + "  Data Count: "
                        + testDesignTreeNode.getChildren().length
                        + "\n");
            }
        }
        int currentCount = 0;
        if (!isEditing) {
            currentCount = selectedNode.getChildren().length;
        }
        if (currentCount != 1 && currentCount != maxCount & maxCount != 0) {
            setModelProperty(CHANGE_LAST_WARNING,
                    "This TestStep has multiple DataObjects and it is marked as DataArrayAppliesToCase, "
                    + "\ntherefore its sibling TestSteps which are also marked as DataArrayAppliesToCase must "
                    + "\nhave the same number of DataObjects or only 1 DataObject attached to it."
                    + "\nCount must be " + maxCount
                    + " at most and 1 at least. \n Current Condition: \n "
                    + statusOfAllNodes.toString());

        }
        return true;
    }

    public boolean checkConstraints() {
        boolean result = checkIfAsyncAndDataAppliesToCaseForUniqueDut();
        if (result) {
            result = checkIfDataAppliesToCaseDataCountsCorrect();
        }
        return result;
    }

    public String checkConstraintBeforeDelete() {//check issue 3968

        TestDesignTreeNode selectedNode = TestDesignControllerList.newInstance().
                getTreeController().getSelectedTreeNode();
        TestDesignTreeNode currentTestStep = null;

        if (!(selectedNode.getObject() instanceof DataObjectRefined)) {
            return "";
        }

        currentTestStep = selectedNode.getParent();
        TestDesignTreeNode currentTestCase = currentTestStep.getParent();
        ArrayList<TestDesignTreeNode> currentTestStepList =
                new ArrayList<TestDesignTreeNode>();
        TestDesignTreeNode[] currentList =
                currentTestCase.getChildren();
        for (int i = 0; i < currentList.length; i++) {
            TestDesignTreeNode testDesignTreeNode = currentList[i];
            if (testDesignTreeNode.getObject() instanceof TestStepRefined) {
                currentTestStepList.add(testDesignTreeNode);
            }
        }
        TestDesignTreeNode[] currentTestSteps =
                new TestDesignTreeNode[currentTestStepList.size()];
        for (int i = 0; i < currentTestSteps.length; i++) {
            currentTestSteps[i] = currentTestStepList.get(i);
        }

        StringBuffer statusOfAllNodes = new StringBuffer();
        int maxCount = 0;
        for (int i = 0; i < currentTestSteps.length; i++) {
            TestDesignTreeNode testDesignTreeNode = currentTestSteps[i];
            Boolean curDataArray = testDesignTreeNode.getReference().getParameterBooleanValue(
                    TestDesignTreeParameters.DataArrayAppliestoCase.name());
            if (curDataArray == null) {
                curDataArray = false;
            }
            if (curDataArray && testDesignTreeNode.getReference().
                    getId()
                    != currentTestStep.getReference().getId()) {
                if (testDesignTreeNode.getChildren().length > maxCount) {
                    maxCount =
                            testDesignTreeNode.getChildren().length;
                }
                statusOfAllNodes.append(" Step Name:" + testDesignTreeNode.getName() + "  Data Count: "
                        + testDesignTreeNode.getChildren().length
                        + "\n");
            }
        }
        int currentCount = currentTestStep.getChildren().length;
        currentCount--;
        if (currentCount != 1 && currentCount != maxCount && maxCount != 0) {
            return "This TestStep has multiple DataObjects and it is marked as DataArrayAppliesToCase, "
                    + "\ntherefore its sibling TestSteps which are also marked as DataArrayAppliesToCase must "
                    + "\nhave the same number of DataObjects or only 1 DataObject attached to it."
                    + "\nCount must be " + maxCount
                    + " at most and 1 at least. \n Current Condition: \n "
                    + statusOfAllNodes.toString();
        }
        return "";
    }

    @Override
    public TestDesignTreeNode operationAddObject(HashMap<String, Object> params, TreeNode node, int childIndex) {
        TestDesignTreeNode nodeToAdd = TestPartSaver.operationAdd(params,
                (TestDesignTreeNode) node, childIndex, "TestStep");

        return nodeToAdd;
    }

    @Override
    public boolean isValidSave(HashMap<String, Object> params, TreeNode node) {
        return true;
    }

    @Override
    public boolean isValidAdd(HashMap<String, Object> params, TreeNode node) {
        return true;
    }
}
